package com.xinxin.leetcode.problem551;

/**
 * @author ShiXinXin
 * @date 2020-01-17 11:40
 */
class Solution {
    public boolean checkRecord(String s) {
        int sum1 = 0, sum2 = 0;
        char[] chs = s.toCharArray();
        for (int i = 0; i < chs.length; i++) {
            if (chs[i] == 'A') {
                if (++sum1 > 1) {
                    return false;
                }
            }
            if (chs[i] == 'L') {
                if (++sum2 > 2) {
                    return false;
                }
            } else {
                sum2 = 0;
            }
        }
        return true;
    }

    // "LLPPPLL" true
    // "PPALLL" false
    public static void main(String[] args) {
        System.out.println(new Solution().checkRecord("LLPPPLL"));
    }
}
